/*点击展开搜索*/

$(function() {
   $(".top_search").click(function() {
	   
	 var uls=document.getElementById("search_box");
	 if(uls.style.display=="block"){
				uls.style.display="none";
				 $(".top_search").css("background-color","#0055ca")
			}else{
				uls.style.display="block";
					 $(".top_search").css("background-color","#2876e0")
			}  
	   
		
	   
   })
});

$(document).ready(function(){
 

  $("#xxjt1").click(function(){
  $("#tab1").show();
  });
  $("#xxjt2").click(function(){
  $("#tab2").show();
  });
   $("#xxjt3").click(function(){
  $("#tab3").show();
  });
/*  var dd = $("#xxjt1").not($(this));
 $("dd").click(function(){
  $("#tab1").hide();
 });*/
	$(".content td").mouseleave(function(){
    $(".more-rep").hide();
	$(".waitxx").hide();

 	});
	
	$(".boxclass li").mouseleave(function(){
	$(".waitxx").hide();
 	});
	
});





 //头部弹出更多e.stopPropagation();

/*$(document).ready(function(){
	$(".xxjt").click(function(e){
	e.stopPropagation();
	$("div.more-rep").removeClass("hide");
});
$(document).click(function(){
	if(!$("div.more-rep").hasClass("hide")){
	$("div.more-rep").addClass("hide");
	}
	});
});*/

/*$(function(){	
 $(".dk-list a.xxjt").click(function() {
	var id = $(this).attr("id");
	if(id=="xxjt-1"){
		$("#fn-1").css("display","block");
		$("#fn-2").css("display","none");
		$("#fn-3").css("display","none");
		$("#fn-4").css("display","none");
	}
	else if(id=="xxjt-2"){
		$("#fn-2").css("display","block");
		$("#fn-1").css("display","none");
		$("#fn-3").css("display","none");
		$("#fn-4").css("display","none");
	  }
    else if(id=="xxjt-3"){
		$("#fn-3").css("display","block");
		$("#fn-2").css("display","none");
		$("#fn-1").css("display","none");
		$("#fn-4").css("display","none");
	}
	else if(id=="xxjt-4"){
		$("#fn-4").css("display","block");
		$("#fn-2").css("display","none");
		$("#fn-3").css("display","none");
		$("#fn-1").css("display","none");
	}
	})
});
*/

/*点击查看更多*/
$(function(){
	$(".click_more").click(function(){
		$(this).hide();
		$(this).next().toggle();	
	});
});


/*清楚搜索关键词*/

function cancelHotWord() { $("#newkeyword").val(""); $("#newkeyword").focus() }
Date.prototype.dateAdd = function (interval, number) {
    var d = this;
    var k = {
        y: "FullYear",
        q: "Month",
        m: "Month",
        w: "Date",
        d: "Date",
        h: "Hours",
        n: "Minutes",
        s: "Seconds",
        ms: "MilliSeconds"
    };
    var n = {
        q: 3,
        w: 7
    };
    eval("d.set" + k[interval] + "(d.get" + k[interval] + "()+" + ((n[interval] || 1) * number) + ")");
    return d
};
Date.prototype.dateDiff = function (b, a) {
    var g = this,
    e = {},
    c = g.getTime(),
    f = a.getTime();
    e.y = a.getFullYear() - g.getFullYear();
    e.q = e.y * 4 + Math.floor(a.getMonth() / 4) - Math.floor(g.getMonth() / 4);
    e.m = e.y * 12 + a.getMonth() - g.getMonth();
    e.ms = a.getTime() - g.getTime();
    e.w = Math.floor((f + 345600000) / (604800000)) - Math.floor((c + 345600000) / (604800000));
    e.d = Math.floor(f / 86400000) - Math.floor(c / 86400000);
    e.h = Math.floor(f / 3600000) - Math.floor(c / 3600000);
    e.n = Math.floor(f / 60000) - Math.floor(c / 60000);
    e.s = Math.floor(f / 1000) - Math.floor(c / 1000);
    return e[b]
};
var getDate = function (a) {
    var f = /^(\d{4})-(\d{2})-(\d{2})$/.exec(a);
    var c = parseInt(f[1], 10);
    var e = parseInt(f[2], 10) - 1;
    var b = parseInt(f[3], 10);
    var d = new Date();
    d.setFullYear(c);
    d.setMonth(e);
    d.setDate(b);
    return d
};
$(function () {
    $(".search input").attr("autocomplete", "off");
    if (jQuery("#newkeyword").length > 0) {
        search_old = $("#newkeyword").val().trim();
        //searchSuggestionContent();
        search_old2 = search_old;
        $("#newkeyword").focus(function () {
            if (search_old2 == $("#newkeyword").val().trim() && $("#newkeyword").attr("cleardefault") != "no") {
                $("#newkeyword").val("")
            }
        });
        $("#newkeyword").blur(function () {
            if ($("#newkeyword").val().trim() == "") {
                $("#newkeyword").val(search_old2);
                $("#newkeyword").attr("style", "color:#999999;")
            }
        })
    }
    if ($("#btnHwkey")) {
        $("#btnHwkey").click(function () {
            if ($("#hwkey").css("display") == "none") {
                $("#hwkey").show()
            }
            else {
                $("#hwkey").hide()
            }
        });
    }
    var a = window.location.href.replace(/(^http:\/\/)|(\/*$)/g, "");
    if (a.indexOf("/") < 0 || (a.split("/").length <= 2 && a.indexOf("/index") >= 0)) {
        $("#hwkey .new-tbl-cell").eq(0).children().addClass("on")
    }
    if (a.indexOf("/category/all.html") > -1) {
        $("#hwkey .new-tbl-cell").eq(1).children().addClass("on")
    }
    if (a.indexOf("/cart/cart.html") > -1) {
        $("#hwkey .new-tbl-cell").eq(2).children().addClass("on")
    }
    if (a.indexOf("/user/") > -1) {
        $("#hwkey .new-tbl-cell").eq(3).children().addClass("on")
    }
    if ($("#btnHwBox")) {
        $("#btnHwBox").click(function () {
            $("#_hwBox").hide();
            $("#_hwSearch").show();
            $("#newkeyword").focus()
        })
    }
    if ($("#_cancelSearch")) {
        $("#_cancelSearch").click(function () {
            //closeSuggestion();
            $("#_hwSearch").hide();
            $("#_hwBox").show()
        })
    }
});